// Michael Depuy
// depuym@onid.orst.edu
// CS 311, Section 400
// Homework 1

/*

  $RCSfile$
  $Revision$
  $Author$
  $Date$
  $Log$

  from:
  http://www.programmingsimplified.com/c-program-read-file

 */

#include "read_file.h"

int main()
{
   char ch, file_name[25];
   //FILE *fp;
   int fd;
   int num_read;
 
   printf("Enter the name of file you wish to see\n");
   scanf(file_name);

   fd = open(file_name, O_RDONLY);
   if (fd < 0)
     {
       pError("Error while opening the file.\n");
       exit(EXIT_FAILURE);
     }
   printf("The contents of %s file are :\n", file_name);

   int i;
   for (i=0;i<;i++)
     {
       num_read = read(fd, &ch, sizeof(ch));
       if (num_read < 0)
	 {
	   perror("Error while reading the file.\n");
	   exit(EXIT_FAILURE);
	 }
       write(STDOUT_FILENO, ch, sizeof(ch));
     }
   return 0;
}
